<template>
  <div>
    <input v-focus type="text" ref="ipt" placeholder="搜索框" v-if="showipt" />
    <button @click="handleSearch">搜索</button>

    <div v-color="color">传智</div>
    <button @click="color='red'">点击改变</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      showipt: false,
      color:'blue'
    }
  },
  directives: {
    focus: {
      inserted(el) {
        el.focus()
      },
    },
   
  },
  methods: {
    handleSearch() {
      this.showipt = true
    },
  },
}
</script>

<style></style>
